<?php
/* $Id$ */

require_once "lib/BaseLibrary.class.php";

/**
 * Benutzt die "ming" Erweiterung
 */

class ShockwaveFlashBase extends BaseLibrary {

	private $label_types_arr		= array(
			"text",
			"button",
			"picture",
			"picture_actionscript"

	);

	private $currentMovie			= null;

	private $labelList_arr			= null;

	private $registeredActionScripts_arr	= null;

	function ShockwaveFlashBase() {

		/* Setzt PHP Konfigvariable */
		ini_set('max_execution_time','3600');

		/* Superklasse aufrufen */
		$this->BaseLibrary( get_class($this), array( "ming" ) );

		/* Umgebungs Abfrage */
		$this->base_environment_extensions_neededAtLeastOrDie_html( 
			1,
			array( "ming" ),
			"Ich benoetige mindestens eine der Erweiterungen {baselibrary_extension_listAsString}"
		);

		/* Mindest Flash Version 7 */
		ming_useswfversion(7);

	}

	function registerActionScript( $triggerName, $code ) {
		$this->registeredActionScripts_arr[$triggerName] = $code;
	}

	function registerActionScriptFile( $triggerName, $fileName ) {
		if ( file_exists( $fileName ) )
			$this->registerActionScript( $triggerName, file_get_contents( $fileName ) );
		else
			$this->dieByError ("Konnte ".$fileName." nicht lesen");
	}

	function getActionScriptByName( $name ) {
		return 	$this->getTemplateProcessor()->
			processString( $this->registeredActionScripts_arr[$name] ); 

	}

	function movie_registerLabel( $label, $type ) {
		if ( $this->movie_isValidLabel( $type ) ) {
			$this->labelList_arr[ $label ] = $type;
		} else
			$this->dieByError ("Falscher Label Typ \"".$type."\"");
	}

	function movie_isValidLabel( $type ) {
		foreach ( $this->getLabelTypes_arr() as $labelType ) {
			if ( $labelType == $type ) return true;
		}
		return false;
	}

	function movie_getLabelTypes_arr() {
		return $this->label_types_arr;
	}

	function getCurrentMovie_obj() {
		return $this->currentMovie;
	}

	function createNewMovie() {
		$this->currentMovie = new SWFMovie(); 
	}

	function saveMovieToFile( $filename ) {

		return ( $currentMovie == null ) ? false: $this->getCurrentMovie()->save( $filename );

	}








}



?>